Using mipmaps

Use mipmaps to create a set of downscaled sublevels from a large texture. Mipmaps increase the GPU memory use by one third, but improve the performance when the full texture does not have to be sampled. Use mipmaps to improve the performance whenever you scale a textured node.

For example, a 256 by 256 pixels texture has mipmap levels that reduce the texture to 128 by 128, 64 by 64, and so on until 1 by 1 pixel. The performance improves because smaller mipmap levels fit better in the fixed-size texture cache in the GPU.

When you create mipmaps in a third-party tool and include them in a .dds file, Kanzi Studio extracts the images for mipmap levels and uses them.

Avoid creating mipmaps from .jpeg textures, because the .jpeg image format causes the quality of the mipmaps to degrade.

Generating mipmaps for a texture

When you import an image that does not contain mipmaps, you can generate the mipmaps for the texture from that image in Kanzi Studio.

To generate mipmaps for a texture:

  1. In the Library select Resource Files > Images, and select the image for which you want to create mipmaps.
    Avoid creating mipmaps from .jpeg textures, because the .jpeg image format causes the quality of the mipmaps to degrade.
  2. In the Properties enable the Generate Mipmaps property.
  3. In the Library > Materials and Textures > Textures select the texture that uses the image for which you want to generate mipmaps and in the Properties set the Mipmap Mode property to Linear or Nearest to take the mipmaps into use. See Filtering textures.
  4. When you export the kzb file of your project and Kanzi Studio asks whether you want to preprocess the images, click Yes.
    If you do not preprocess images in Kanzi Studio, Kanzi Engine generates mipmaps when it loads your application on the target device. This increases the loading time of your application.
    NOTE

    Kanzi cannot generate mipmaps for images that use ASTC, ATC, ETC, or PVRTC compression.

    TIP

    To manually generate mipmaps for images, in the Library right-click the image for which you want to generate mipmaps and select Preprocess images.

Creating mipmaps for a composition target

You can create mipmaps for a composition target when you render 3D content with a Composition Target Render Pass. For example, use this to create a low-quality blur effect that is quick to render.

This procedure explains how to create mipmaps for a composition target which Kanzi creates automatically. To create mipmaps for a Render Target Texture, see Creating mipmaps for a Render Target Texture.

To create mipmaps for a composition target:

  1. Create the render passes that you need to render your content to a composition target. See Rendering content to a composition target.

  2. In the Library > Rendering > Render Passes select the Composition Target Render Pass, in the Properties add the Mipmap Mode property, and set it either to Linear or Nearest. See Filtering textures.
    Kanzi generates the mipmaps when you render the composition target.

Creating mipmaps for a Render Target Texture

You can create mipmaps for a Render Target Texture to which you render 3D content with a Composition Target Render Pass. For example, use this to create a low-quality blur effect that is quick to render.

To create mipmaps for a Render Target Texture:

  1. In the Library > Rendering > Render Passes create a Render to Texture Pass.
    Render to Texture Pass creates the render passes and texture you need to render to a texture. See Rendering to texture.
  2. In the Project select the Scene node the content of which you want to render to a texture and in the Properties set the Render Pass property to the Render to Texture Pass you created in the previous step.
    Kanzi now renders the Scene using the render passes you created.
  3. In the Library select the Render to Texture Pass that you created, in the Properties click next to the Composition Target property to go to the Render Target Texture resource, and set the Mipmap Mode property to either Linear or Nearest. See Filtering textures.
  4. In the Library select the Render to Texture Pass that you created and in the Properties add and enable the Resolve Immediately property.
    When you enable the Resolve Immediately property, Kanzi resolves multisamples and generates mipmaps for the Render Target Texture immediately after rendering the texture. If you do not enable the Resolve Immediately property, Kanzi generates the mipmaps only when you refer to the Render to Texture Pass with another render pass.
  5. Use the Render Target Texture in a node where you want to show the 3D content. See Using render target textures.

Creating custom mipmap levels for a Render Target Texture

When you use a Render Target Texture on 3D geometry, you can use Legacy Render Pass (deprecated) resources to create custom mipmap levels for the Render Target Texture.

To create custom mipmap levels for a Render Target Texture:

  1. In the Library > Materials and Textures > Textures select the Render Target Texture for which you want to generate mipmaps, and in the Properties set the Mipmap Mode property to either Linear or Nearest. See Filtering textures.
  2. To create a custom mipmap for each mipmap level, in the Library > Rendering > Render Passes create one Legacy Render Pass (deprecated) for each mipmap level, and set the Mipmap Level property to the mipmap level in which you want to use the result of that Legacy Render Pass (deprecated).
    For example, if your Render Target Texture measures 512 by 512 pixels, to create all mipmap levels you need ten Legacy Render Pass (deprecated) render passes. For the Legacy Render Pass (deprecated) that renders the mipmap the size of the texture set the Mipmap Level property to 0, for the Legacy Render Pass (deprecated) that renders the next mipmap level (256 by 256 pixels) set the Mipmap Level property to 1, and so on until the mipmap texture that measures 1 by 1 pixel.

See also

Adjusting the data size

Loading resources in parallel

Compressing textures

Filtering textures

Troubleshooting the performance of your application

Images and textures best practices

Best practices

Rendering content to a composition target